package com.chen.lifepic.LargeViewFragment;

import java.util.Vector;

import android.content.Context;
import android.util.AttributeSet;
import android.util.Log;
import android.view.MotionEvent;
import android.widget.LinearLayout;

import com.chen.lifepic.DataProvider.BaseDataProvider;

public class LargeView extends LinearLayout {
	Vector<LargeSubView> threeSubViews = null;

	Context _context = null;

	BaseDataProvider _dataProvider = null;

	public LargeView(Context context) {
		super(context);
		init(context);
	}

	public LargeView(Context context, AttributeSet attrs) {
		super(context, attrs);
		init(context);
	}

	public void setDataProvider(BaseDataProvider dataProvider) {
		_dataProvider = dataProvider;
	}

	void init(Context context) {
		_context = context;
		initLargeSubViews();
	}

	void initLargeSubViews() {
		threeSubViews = new Vector<LargeSubView>();

		LargeSubView subView0 = new LargeSubView(_context);
		threeSubViews.add(subView0);
		this.addView(subView0);

		LargeSubView subView1 = new LargeSubView(_context);
		threeSubViews.add(subView1);
		this.addView(subView1);

		LargeSubView subView2 = new LargeSubView(_context);
		threeSubViews.add(subView2);
		this.addView(subView2);
	}

	void didMoveToNext() {
		// �ڻ�������һҳ�󣬽����һ��view�ƶ�����һ��
		LargeSubView subView2 = threeSubViews.get(2);
		threeSubViews.remove(2);

		threeSubViews.add(0, subView2);
	}

	void didMoveToPrev() {
		// �ڻ�������һҳ�󣬽���һ��view�ƶ������һ��
		LargeSubView subView0 = threeSubViews.get(0);
		threeSubViews.remove(0);

		threeSubViews.add(subView0);
	}
	
	@Override
	public boolean onTouchEvent(MotionEvent event) {
		Log.d("test", "touch event = " +event.toString());
		return super.onTouchEvent(event);
	}
}
